﻿using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Media.Animation;

namespace IMClient.View
{
    /// <summary>
    /// ContactsPage.xaml 的交互逻辑
    /// </summary>
    public partial class ContactsView : UserControl
    {
        public ContactsView()
        {
            InitializeComponent();
        }

        
        private void FriendButton_Click(object sender, RoutedEventArgs e)
        {
            // 创建动画：TextBlock 向左滑动到 Margin = "-90,0,0,0"
            ThicknessAnimation animation = new ThicknessAnimation
            {
                From = SlidingTextBlock.Margin,
                To = new Thickness(-90, 0, 0, 0),
                Duration = TimeSpan.FromSeconds(0.3),
                EasingFunction = new QuadraticEase() // 使用平滑效果
            };

            SlidingTextBlock.BeginAnimation(MarginProperty, animation);

            // 更新按钮状态
            FriendButton.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#07c160"));
            FriendButton.FontWeight = FontWeights.Bold;

            GroupButton.Foreground = Brushes.Gray;
            GroupButton.FontWeight = FontWeights.Normal;
        }

        private void GroupButton_Click(object sender, RoutedEventArgs e)
        {
            // 创建动画：TextBlock 向右滑动到 Margin = "90,0,0,0"
            ThicknessAnimation animation = new ThicknessAnimation
            {
                From = SlidingTextBlock.Margin,
                To = new Thickness(90, 0, 0, 0),
                Duration = TimeSpan.FromSeconds(0.3),
                EasingFunction = new QuadraticEase() // 使用平滑效果
            };

            SlidingTextBlock.BeginAnimation(MarginProperty, animation);

            // 更新按钮状态
            GroupButton.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#07c160"));
            GroupButton.FontWeight = FontWeights.Bold;

            FriendButton.Foreground = Brushes.Gray;
            FriendButton.FontWeight = FontWeights.Normal;
        }

        private void Add_Button_Click(object sender, RoutedEventArgs e)
        {
            var button = (Button)sender;
            button.ContextMenu.IsOpen = true;
        }
    }
}
